<?php

        /***************************************************************
        * Core settings for all apps, and all environments
        */
        define('SESSION_TIME_OUT', 30); // Minutes

        if ( preg_match("/win32/i",$_SERVER['SERVER_SOFTWARE']) ) {
                define('OS','windows');
        }
        // In the absence of a cleaner way of determining if the server is a Mac...
        else if ( is_dir("/System/Library/Frameworks") )
        {
                define('OS','mac');
        }
        else
        {
                define('OS','unix');
        }

        define('PHP_INI_SEPERATOR',(OS == 'windows') ? ';' : ':');

        /***************************************************************
        * Which environment are we on?
        */

        if ( $_SERVER['SERVER_NAME'] == 'cargo-stream.dev' )
        {
                define('DB_HOST',    'staging');
                define('DB_LOGIN',   'staging');
                define('DB_PWD',     'staging');
                define('DB_NAME',    'staging');
                define('DB_PREFIX',  'cargo_');
                define('ENVIROMENT', 'dev');
                define('CORE_DIR', '');
                error_reporting(E_ALL);
        }
        elseif ( in_array( $_SERVER['SERVER_NAME'], array( 'cargo-stream.ru', 'www.cargo-stream.ru' ) ))
        {
                define('DB_HOST',    'agladyshev.mysql');
                define('DB_LOGIN',   'agladyshev_mysql');
                define('DB_PWD',     'gtw1lhwy');
                define('DB_NAME',    'agladyshev_db');
                define('DB_PREFIX',  'cargo_');
                define('ENVIRONMENT','live');
                define('CORE_DIR',   'core');
                error_reporting(0);
        }
        else
        {
                define('DB_HOST',    '127.0.0.1');
                define('DB_LOGIN',   'root');
                define('DB_PWD',     'root');
                define('DB_NAME',    'globalmessenger');
                define('DB_PREFIX',  'gm_');
                define('ENVIRONMENT','localhost');
                define('CORE_DIR',   '../core');
                error_reporting(E_ALL);
         }

         // Repository paths
//         define('SITE_REPOSITORY',   'http://site-cargo-shesternin.googlecode.com/svn/trunk/');
         define('CORE_REPOSITORY',   'http://core-cargo-shesternin.googlecode.com/svn/trunk/');

        // Set PEAR lookup path
        // Note: Windows/unix use different spereators for php.ini
        ini_set('include_path','.'.PHP_INI_SEPERATOR.'./third_party/Pear');




        /***************************************************************
        * Debug?
        */
        if ( isset($_REQUEST['debug']) && $_REQUEST['debug'] == 'off' ) {
                unset($_SESSION['debug']);
        }
        elseif ( isset($_REQUEST['debug']) || isset($_SESSION['debug']) ) {
                define('DEBUG',true);

                // Turn on debug for the rest of this session
                // (Need to close browser to stop)
                $_SESSION['debug'] = true;
        } else {
                define('DEBUG',false);
        }



        /***************************************************************
        * Make sure that REQUEST_URI is always set (used in TRAGET)
        */

        if ( ! isset($_SERVER['REQUEST_URI']))
        {
                $_SERVER['REQUEST_URI'] = '';
        }